import { request } from '@/base/Request';
import { ModeUseNumVo } from '@/base/model/ModeUseNumVo';
import { ModeLifetimeVo } from '@/base/model/ModeLifetimeVo';
import { DeviceUse } from '@/base/model/DeviceUse';
import { Result } from '@/base/Result';

export function getDeviceUseList(params: {
  pageIndex: number,
  pageSize: number,
  sortDirection: string,
  affiliateId?: number,
  createBegin?: string,
  createEnd?: string,
  companyId?: number,
  deviceId?: number
}) {
  return request.getPage(DeviceUse, '/api/device-use/fetchDeviceUse', { params });
}

export function getDeviceUseModelLifetime(
  params: {
    deviceId?: number,
    companyId?: number,
    deviceModelId?: number
  }) {
  return request.getArray(ModeLifetimeVo, `/api/device-use/mode/lifetime`, { params })
}

export function getDeviceUseModeUse(
  params: {
    deviceId?: number,
    companyId?: number,
    deviceModelId?: number
  }) {
  return request.getArray(ModeUseNumVo, `/api/device-use/mode/use`, { params })
}

export function deleteDeviceUse(id: number): Promise<Result<void>> {
  return request.delete(`/api/device-use/${id}`);
}
export function deleteDeviceFault(id: number): Promise<Result<void>> {
  return request.delete(`/api/device-fault/${id}`);
}
